package org.dromara.system.utils;

import lombok.experimental.UtilityClass;
import org.dromara.common.redis.common.RedisConstants;
import org.dromara.common.redis.utils.RedisUtils;
import org.dromara.system.domain.pojo.NoticeVo;
import org.dromara.system.domain.vo.DataBaseVo;

import java.util.Date;

@UtilityClass
public class NoticeUtils {

    public static NoticeVo getNoticeInfo() {
        NoticeVo cacheObject = RedisUtils.getCacheObject(RedisConstants.NOTICE_PREFIX);
        if (cacheObject == null) {
            cacheObject = new NoticeVo();
            initializeStatusInfos(cacheObject);
            RedisUtils.setCacheObject(RedisConstants.NOTICE_PREFIX, cacheObject);
        }
        return cacheObject;
    }

    private static void initializeStatusInfos(NoticeVo noticeVo) {
        noticeVo.setTitle("综合管养");
    }

    public static NoticeVo setTitle(String title) {
        RedisUtils.deleteKeys(RedisConstants.NOTICE_PREFIX);
        NoticeVo noticeVo = new NoticeVo();
        noticeVo.setTitle(title);

        RedisUtils.setCacheObject(RedisConstants.NOTICE_PREFIX, noticeVo);
        return noticeVo;
    }


}
